package com.google.code.sip.ucenter.model;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Indexed;

/**
 * 角色.
 * 
 * 注释见{@link User}.
 * 
 * @author calvin
 */
@SuppressWarnings("serial")
@Entity(noClassnameStored = true)
public class Role extends BaseEntity {
	public static final String ROLE_PREFIX = "ROLE_";
	public static final String ADMIN = "ADMIN";
	public static final String NORMAL = "NORMAL";
	@Indexed(unique = true)
	private String name;
	private String description;

	public Role() {

	}

	public Role(String id, String name) {
		super.setId(id);
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getPrefixedName() {
		return ROLE_PREFIX + name;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
